Skip to content

Cache View plugin for Flowaxy CMS provides a user-friendly interface for viewing and managing system cache. The plugin displays cache statistics, allows viewing cache files, identifies cache sources (plugins, themes, system), checks cache expiry status, and provides tools for clearing cache.

Notifications You must be signed in to change notification settings

flowaxy/cache-view

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Cache View Plugin

Version: 1.0.0
License: Proprietary
Developer: iTeffa (iteffa@flowaxy.com)
Studio: FLOWAXY
Website: https://flowaxy.com

Description

Cache View plugin for Flowaxy CMS provides a user-friendly interface for viewing and managing system cache. The plugin displays cache statistics, allows viewing cache files, identifies cache sources (plugins, themes, system), checks cache expiry status, and provides tools for clearing cache.

Screenshot

Cache View Plugin Screenshot

Note: For the best visual experience, refer to the screenshot in the assets/images/ directory.

Features

Core Features

  • πŸ“Š Cache Statistics β€” View total files count, total cache size, and expired items count
  • πŸ“ Cache File Listing β€” Browse all cache files with detailed information
  • πŸ” Cache Source Detection β€” Automatically identifies cache sources:
    • Plugin cache (shows plugin name)
    • Theme cache (shows theme name)
    • System cache (shows cache type label and category)
  • πŸ”₯ Activity Heatmap β€” Visual indicators showing cache usage frequency:
    • πŸ”΄ High activity β€” Frequently accessed cache items
    • 🟑 Medium activity β€” Moderately used cache items
    • 🟒 Low activity β€” Rarely accessed cache items
    • Shows access count and last access time
  • ⏰ Expiry Status β€” Checks if cache items are expired or active
    • Shows expiry time and remaining time for active items
    • Highlights expired items
  • πŸ‘οΈ Cache Content Viewer β€” View cache file content in JSON, PHP Array, or raw text format
  • πŸ—‘οΈ Cache Management β€” Clear entire cache or individual cache items
  • πŸ”„ Sortable Table β€” Sort cache items by key, source, status, size, or modification date
  • πŸ“± Responsive Design β€” Mobile-friendly interface with adaptive layouts
    • Desktop: Full table view with all details
    • Mobile: Card-based layout optimized for small screens
  • βœ… Access Control β€” Permission-based access to cache management

Technical Capabilities

  • File system cache scanning
  • Cache file content analysis (deserialization)
  • Integration with Flowaxy CMS cache settings
  • Timezone-aware cache expiry checking
  • Modal dialogs for safe cache clearing

Requirements

  • PHP >= 8.4.0
  • Flowaxy CMS with plugin support
  • Read/write access to cache directory
  • Admin access for cache management

Installation

  1. Copy the plugin directory to plugins/cache-view/.
  2. Activate the plugin via the admin panel (Settings β†’ Plugins).
  3. The plugin will automatically register its route and menu item.

No database tables are required - the plugin works with existing cache files.

Usage

Accessing the Cache View Page

  1. Log in to the admin panel.
  2. Navigate to System β†’ Cache View in the menu.
  3. Or go directly to /admin/cache-view.

Viewing Cache Statistics

The plugin displays three main statistics cards:

  • Total Files β€” Number of cache files
  • Total Size β€” Total cache size (KB or MB)
  • Expired Items β€” Number of expired cache items

Cache File Information

Each cache file shows:

  • Key β€” Cache key (filename without extension)
  • Source β€” Where the cache comes from:
    • Plugin name (if from a plugin)
    • Theme name (if from a theme)
    • System cache type (e.g., "Site Settings", "Admin Menu")
  • Cache Type β€” Category of cache (routes, translations, configuration, user, etc.)
  • Activity β€” Usage frequency indicator:
    • πŸ”΄ Часто (High) β€” Frequently accessed (60+ score)
    • 🟑 Π‘Π΅Ρ€Π΅Π΄Π½ΡŒΠΎ (Medium) β€” Moderate usage (20-60 score)
    • 🟒 Π Ρ–Π΄ΠΊΠΎ (Low) β€” Rarely accessed (<20 score)
    • Shows access count and last access time
  • Status β€” Cache expiry status:
    • 🟒 Active β€” Cache is valid (shows remaining time)
    • πŸ”΄ Expired β€” Cache has expired (shows time ago)
    • βšͺ Unknown β€” Cannot determine expiry status
  • Size β€” File size (KB or MB)
  • Updated β€” Last modification time
  • Actions β€” View content and delete buttons for individual cache items

Sorting and Filtering

  • Click on column headers to sort cache items:
    • Key β€” Sort alphabetically by cache key
    • Source β€” Sort by cache source
    • Activity β€” Sort by activity level (high β†’ low)
    • Status β€” Sort by expiry status
    • Size β€” Sort by file size
    • Updated β€” Sort by modification date
  • Sort direction toggles between ascending and descending
  • Visual sort indicators show current sort column and direction

Clearing Cache

Clear All Cache

  1. Click the "Clear All Cache" button in the page header.
  2. Confirm the action in the modal dialog.
  3. All cache files will be deleted (system files like .gitkeep and .htaccess are preserved).

Note: The button is disabled when cache is empty.

View Cache Content

  1. Click the eye icon (πŸ‘οΈ) next to any cache item.
  2. The cache content will be displayed in a modal dialog.
  3. View content in three formats:
    • JSON β€” Formatted JSON representation
    • PHP Array β€” PHP var_export format
    • Raw β€” Raw text content (for non-serialized data)

Clear Individual Cache Items

  1. Click the trash icon (πŸ—‘οΈ) next to any cache item.
  2. Confirm the action in the modal dialog.
  3. The selected cache file will be deleted.

Cache Expiry Checking

The plugin checks cache expiry by:

  1. Reading cache file content
  2. Looking for expires field in serialized data
  3. If expires is missing, calculating expiry using:
    • created timestamp + cache_default_ttl from system settings
  4. Comparing with current time to determine status

Cache settings are retrieved from:

  • cache_enabled β€” Whether caching is enabled
  • cache_default_ttl β€” Default cache lifetime (seconds)

Plugin Structure

cache-view/
β”œβ”€β”€ assets/
β”‚   β”œβ”€β”€ images/
β”‚   β”‚   └── screenshot.png       # Plugin screenshot
β”‚   └── styles/
β”‚       └── cache-view.css       # Styles for the cache view page
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ admin/
β”‚   β”‚   └── pages/
β”‚   β”‚       └── CacheViewAdminPage.php  # Admin page controller
β”‚   └── Services/
β”‚       └── CacheStatsTracker.php       # Cache activity tracking service
β”œβ”€β”€ templates/
β”‚   └── cache-view.php           # Cache view page template
β”œβ”€β”€ tests/
β”‚   └── CacheViewPluginTest.php  # Diagnostic tests
β”œβ”€β”€ .gitignore                   # Git ignore rules
β”œβ”€β”€ init.php                     # Plugin initialization
β”œβ”€β”€ plugin.json                  # Plugin metadata
└── README.md                    # Documentation

Technical Details

Architecture

The plugin uses a service-oriented architecture:

  • CacheViewAdminPage β€” Admin panel page for cache management
  • CacheStatsTracker β€” Service for tracking cache access statistics
  • Templates β€” PHP templates for HTML rendering
  • Components β€” Reusable admin UI components:
    • stats-cards.php β€” Statistics cards
    • data-table.php β€” Sortable data table
    • empty-state.php β€” Empty state display
    • info-block.php β€” Information blocks
    • modal.php β€” Modal dialogs

Cache Source Detection

The plugin determines cache source by:

  1. Key Pattern Analysis β€” Checks for known prefixes:

    • plugin_data_* β€” Plugin cache
    • theme_settings_*, theme_config_*, theme_* β€” Theme cache
    • Other keys β€” System cache
  2. Content Analysis β€” For generic hash keys:

    • Unserializes cache file content
    • Checks data structure:
      • Plugin data: Contains id, slug, name, installed_at fields
      • Theme data: Contains slug, name, is_default, supports_customization fields
      • System data: Analyzes structure to determine cache type (routes, translations, configuration, etc.)

Cache Activity Tracking

The plugin tracks cache access to display activity heatmap:

  • Automatic Tracking β€” Integrated into the core Cache class
  • Activity Score β€” Calculated based on:
    • Recent 24-hour activity (60% weight)
    • Recent 7-day activity (30% weight)
    • Total access count (10% weight)
  • Activity Levels:
    • High (60-100 score) β€” Frequently accessed
    • Medium (20-60 score) β€” Moderate usage
    • Low (0-20 score) β€” Rarely accessed
  • Statistics Storage β€” Saved to .cache-stats.json in cache directory
  • Auto-cleanup β€” Old statistics (30+ days) are automatically removed

Cache Expiry Detection

The plugin checks cache expiry status:

  1. Reads cache file and unserializes content
  2. Looks for expires timestamp field
  3. If missing, calculates: created + cache_default_ttl (from settings)
  4. Compares with current time:
    • Active β€” expires > current_time
    • Expired β€” expires < current_time
    • Unknown β€” Cannot determine expiry

Security

  • βœ… CSRF protection for all write operations
  • βœ… Access permission checks before executing operations
  • βœ… Path traversal protection when accessing cache files
  • βœ… XSS protection via output sanitization
  • βœ… System file protection (.gitkeep, .htaccess are never deleted)

Hooks

The plugin uses the following hooks:

  • admin_register_routes β€” Register admin route
  • admin_menu β€” Add menu item to System section
  • settings_categories β€” Add plugin to settings page

Components Used

The plugin utilizes reusable admin components:

  • Stats Cards β€” For displaying statistics (total files, size, expired)
  • Data Table β€” For displaying cache items with sorting
  • Empty State β€” For displaying "Cache is empty" message
  • Info Block β€” For displaying system cache information
  • Modal β€” For confirmation dialogs

Configuration

Cache Settings

The plugin respects cache settings from Site Settings (/admin/site-settings):

  • Enable Caching β€” Whether caching is enabled
  • Cache Default TTL β€” Default cache lifetime (seconds)
  • Auto Cleanup β€” Automatic cleanup of expired cache

These settings affect:

  • Expiry status calculation
  • Cache source detection
  • Statistics display

Default Behavior

By default, the plugin:

  • Shows all cache files from the cache directory
  • Filters out system files (.gitkeep, .htaccess)
  • Displays cache statistics
  • Allows clearing cache (if user has permissions)
  • Sorts cache items by modification date (newest first)

Development

Dependencies

The plugin uses the following components from the Engine:

  • engine/core/support/base/BasePlugin.php
  • engine/interface/admin-ui/includes/AdminPage.php
  • engine/core/support/helpers/UrlHelper.php
  • engine/core/support/helpers/SecurityHelper.php
  • engine/core/support/managers/SettingsManager.php (for cache settings)
  • engine/core/support/managers/PluginManager.php (for plugin name resolution)
  • engine/core/support/managers/ThemeManager.php (for theme name resolution)

Extending Functionality

To extend the plugin:

  1. Add new cache source types β€” Modify detectCacheSource() method in CacheViewAdminPage.php
  2. Add new statistics β€” Extend getCacheInfo() method and update template
  3. Customize expiry checking β€” Modify checkCacheExpiry() method
  4. Add filtering options β€” Extend template with filter UI and update getCacheInfo()
  5. Customize UI β€” Edit templates/cache-view.php and assets/styles/cache-view.css

Cache Directory

The plugin reads from the cache directory defined by:

  1. CACHE_DIR constant (if defined)
  2. ROOT_DIR . '/storage/cache' (default)
  3. Fallback to dirname(__DIR__, 5) . '/storage/cache'

Important: The plugin only reads cache files and never modifies them directly. Cache clearing operations use the Cache API or file system operations with proper access controls.

Troubleshooting

Common Issues

Cache not appearing:

  • Verify cache directory permissions (read access required)
  • Check if cache is enabled in Site Settings
  • Ensure cache files have .cache extension

Cannot clear cache:

  • Verify user has admin.cache.clear permission
  • Check cache directory write permissions
  • Ensure system files (.gitkeep, .htaccess) are not missing

Expiry status showing as "Unknown":

  • Verify cache files are properly serialized
  • Check cache_default_ttl setting in Site Settings
  • Ensure cache files have valid created or expires fields

Getting Help

If you find a bug or have questions:

  1. Check log files for errors (storage/logs/)
  2. Verify cache directory permissions
  3. Ensure cache files are readable
  4. Check system cache settings in Site Settings (/admin/site-settings)
  5. Review the diagnostic tests output

Testing

Diagnostic Tests

The plugin includes a set of diagnostic tests to verify functionality. Tests are located in the tests/ directory:

  • CacheViewPluginTest.php β€” Set of automatic tests to verify:
    • Getting cache info with empty cache
    • Getting cache info with files
    • Cache source detection (system cache)
    • Cache expiry checking (active and expired)
    • Getting cache settings from database
    • Time formatting (time ago and time left)
    • Clear cache button creation (enabled and disabled states)

Tests are automatically loaded through Flowaxy CMS TestService and TestRunner system.

Running Tests

To run the diagnostic tests:

php engine/application/testing/cli/run-tests.php --plugin=cache-view

Or use the Flowaxy CMS test runner:

php flowaxy test --plugin=cache-view

Quick Cache Test

You can test cache functionality manually by:

  1. Creating test cache files manually
  2. Checking if they appear in the cache view
  3. Verifying expiry status
  4. Testing cache clearing functionality

License

Proprietary. All rights reserved.

Changelog

1.0.0 (2025-11-30)

Initial Release

  • ✨ Initial release
  • βœ… Cache file listing and statistics
  • βœ… Cache source detection (plugin, theme, system)
  • βœ… Cache expiry status checking
  • βœ… Cache clearing (all or individual items)
  • βœ… Sortable table with column sorting
  • βœ… Responsive design (desktop and mobile)
  • βœ… Modal dialogs for confirmations
  • βœ… Integration with Flowaxy CMS Engine
  • βœ… Reusable admin UI components
  • βœ… Empty state handling
  • βœ… Disabled button when cache is empty
  • βœ… Cache activity tracking and heatmap
  • βœ… Cache content viewer (JSON, PHP Array, Raw)
  • βœ… Cache type categorization
  • βœ… Diagnostic tests
  • βœ… CSRF protection
  • βœ… Permission-based access control

Author

FlowAxy
Developer: iTeffa
Email: iteffa@flowaxy.com
Studio: FLOWAXY
Website: https://flowaxy.com

License

Proprietary. All rights reserved.


Developed with ❀️ for Flowaxy CMS

About

Cache View plugin for Flowaxy CMS provides a user-friendly interface for viewing and managing system cache. The plugin displays cache statistics, allows viewing cache files, identifies cache sources (plugins, themes, system), checks cache expiry status, and provides tools for clearing cache.

Topics

Resources

Stars

Watchers

Forks